﻿using AutoMapper;
using QuanLyGiaoVuDAL.DTO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace QuanLyGiaoVuUI.Models.DangKyGioDay
{
    public class DangKyGioDayViewModel
    {
        public System.Guid MaThongTinGiangDay { get; set; }

        public System.Guid GiangVienId { get; set; }

        public System.Guid MaLopMonHoc { get; set; }

        public int MaTietDau { get; set; }

        public int MaTietSau { get; set; }

        public short Thu { get; set; }

        public System.Guid MaHocKy { get; set; }

        public Int16 DoUuTien { get; set; }

        public Boolean DuocChon { get; set; }

        public Boolean Huy { get; set; }

        public String GhiChu { get; set; }

        public int ThuTuTrongTuan { get; set; }

        public GiangVienDTO GiangVienDTO { get; set; }

        public LopMonHocDTO LopMonHocDTO { get; set; }

        public TietHocDTO TietDauDTO { get; set; }

        public TietHocDTO TietSauDTO { get; set; }

        public DangKyGioDayDTO ToDangKyGioDayDTO()
        {
            Mapper.CreateMap(typeof(DangKyGioDayViewModel), typeof(DangKyGioDayDTO));
            var dangKyGioDayDTO = new DangKyGioDayDTO();
            Mapper.Map(this, dangKyGioDayDTO);
            return dangKyGioDayDTO;
        }

        public static IEnumerable<DangKyGioDayDTO> ToDangKyGioDayDTOList(IEnumerable<DangKyGioDayViewModel> dangKyGioDayViewModelList)
        {
            List<DangKyGioDayDTO> dangKyGioDayDTOList = new List<DangKyGioDayDTO>();
            foreach (DangKyGioDayViewModel dangKyGioDayViewModel in dangKyGioDayViewModelList)
            {
                dangKyGioDayDTOList.Add(dangKyGioDayViewModel.ToDangKyGioDayDTO());
            }
            return dangKyGioDayDTOList;
        }

        public static DangKyGioDayViewModel FromDangKyGioDayDTO(DangKyGioDayDTO dangKyGioDayDTO)
        {
            Mapper.CreateMap(typeof(DangKyGioDayDTO), typeof(DangKyGioDayViewModel));
            var dangKyViewModel = new DangKyGioDayViewModel();
            Mapper.Map(dangKyGioDayDTO, dangKyViewModel);
            return dangKyViewModel;
        }

        public static IEnumerable<DangKyGioDayViewModel> FromDangKyGioDayDTOList(IEnumerable<DangKyGioDayDTO> dangKyGioDayDTOList)
        {
            List<DangKyGioDayViewModel> dangKyGioDayViewModelList = new List<DangKyGioDayViewModel>();
            foreach (DangKyGioDayDTO dangKyGioDayDTO in dangKyGioDayDTOList)
            {
                dangKyGioDayViewModelList.Add(DangKyGioDayViewModel.FromDangKyGioDayDTO(dangKyGioDayDTO));
            }
            return dangKyGioDayViewModelList.AsEnumerable<DangKyGioDayViewModel>();
        }

    }
}